<%@ page contentType="text/html;charset=UTF-8"%>

<script type="text/javascript" src="${ctxStatic}/layui-v2.2.45/layui/layui.js"></script>
<!-- build:js -->
<script type="text/javascript" src="${ctx}/script/common/common.js"></script>
<script type="text/javascript" src="${ctx}/script/common/util.js"></script>
<!-- endbuild -->
<script type="text/javascript" src="${ctxStatic}/ZeroClipboard/ZeroClipboard.min.js"></script>

<script>
    $(function(){
        $('.z-copy-btn').each(function (i) {
            clipboard(this, this.dataset.id, this.dataset.msg);
        })
    })
    /**
     *  复制到剪贴板
     * @param button 按钮id
     * @param text 要复制的文本
     * @param msg 复制成功提示文本
     * @returns {boolean}
     */
    function clipboard(btnO,text,msg) {
        if (window.clipboardData) {    //for ie
            btnO.onclick = function () {
                window.clipboardData.setData('text', text);
                util.layerMsgSuccess(msg);
            }
        } else {
            var client = new ZeroClipboard($(btnO));
//            client.setHandCursor(true);
            client.on('ready', function (event) {

                client.on('copy', function (event) {
                    event.clipboardData.setData("text/plain", text);
                    util.layerMsgSuccess(msg);
                });
            });
            client.on('error', function (event) {
                ZeroClipboard.destroy();
            });
        }
        return false;
    }

</script>
